package example

import (
	"echarts_fan/probe"
	"github.com/go-echarts/go-echarts/charts"
	"log"
	"os"
)

func Line() {
	line := charts.NewLine()
	line.SetGlobalOptions(charts.TitleOpts{Title: "Line-显示 Label"},
		charts.ToolboxOpts{Show: true},
		charts.InitOpts{
			Width:      "1800px",
			Height:     "1000px",
			AssetsHost: "http://127.0.0.1:8083/assets/"},
	)
	line.AddXAxis(probe.NameItems).AddYAxis(
		"温度", probe.Xtem,
		// 标记点
		charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	).AddYAxis(
		"湿度", probe.Xhum,
		// 标记点
		//charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		//charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		//charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		//charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	).AddYAxis(
		"压强", probe.Xpre,
		// 标记点
		//charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		//charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		//charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		//charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	).AddYAxis(
		"经度", probe.Xlon,
		// 标记点
		//charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		//charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		//charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		//charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	).AddYAxis(
		"纬度", probe.Xlat,
		// 标记点
		//charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		//charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		//charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		//charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	) /*.AddYAxis(
		"高度", probe.Xheight,
		// 标记点
		//charts.MPNameTypeItem{Name: "最大值", Type: "max"},
		//charts.MPNameTypeItem{Name: "平均值", Type: "average"},
		//charts.MPNameTypeItem{Name: "最小值", Type: "min"},
		//charts.MPStyleOpts{Label: charts.LabelTextOpts{Show: true}},
		// 显示 Label
		charts.LabelTextOpts{Show: false},
		// 阶梯图
		charts.LineOpts{Step: false},
		// 平滑曲线
		charts.LineOpts{Smooth: false},
		// 填充区域
		//charts.AreaStyleOpts{Opacity: 0.2},
	)*/

	line.SetGlobalOptions(
		// 显示分割线
		charts.YAxisOpts{SplitLine: charts.SplitLineOpts{Show: true}},
	)
	f, err := os.Create("line.html")
	if err != nil {
		log.Println(err)
	}
	//生成本地文件
	line.Render(f)
}
